namespace Leetcode;

public interface ITreeNode<T>
{

    T val { get; set; }
    ITreeNode<T> left { get; set; }
    ITreeNode<T> right { get; set; }

}

public class TreeNode : ITreeNode<int>
{
    public int val { get; set; }
    public TreeNode()
    {

    }

    public TreeNode(int val)
    {
        this.val = val;
    }

    public TreeNode(int val, TreeNode left, TreeNode right)
    {
        this.val = val;
        this.left = left;
        this.right = right;
    }

    public TreeNode left { get; set; }
    public TreeNode right { get; set; }

    ITreeNode<int> ITreeNode<int>.left
    {
        get
        {
            return this.left;
        }
        set
        {
            this.left = value as TreeNode;
        }
    }

    ITreeNode<int> ITreeNode<int>.right
    {
        get
        {
            return this.right;
        }
        set
        {
            this.right = value as TreeNode;
        }
    }
}